package org.rayworks.downloadutils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class DownloadReceiver extends BroadcastReceiver {
	public static final String ACTION_TYPE = "org.rayworks.downloadutils.loaded";

	public static interface DownloadCompleteListener {
		void onLoadedComplete(byte[] data);
	}

	private DownloadCompleteListener mListener = null;

	void setListener(DownloadCompleteListener l) {
		mListener = l;
	}

	public DownloadReceiver() {
	}

	@Override
	public void onReceive(Context ctx, Intent intent) {
		
		if(mListener != null && intent != null && intent.getAction().equals(ACTION_TYPE)){
			mListener.onLoadedComplete(intent.getByteArrayExtra(DownloadService.DATA_TAG));
		}
	}

}
